import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { NewsProvider } from '../../providers/news/news';
import { Carousel } from '../../app/model/carousel';
import { CarouseldetailPage } from '../carouseldetail/carouseldetail';
import { News } from '../../app/model/news';
import { NewsdetailPage } from '../newsdetail/newsdetail';
import { ConfigProvider } from '../../providers/config/config';


@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  cl:Array<Carousel>
  nl:Array<News>

  PICHOST:string

  constructor(public navCtrl: NavController,private newsService:NewsProvider,
  private configservice:ConfigProvider) {
    this.PICHOST = configservice.HOST+"/public/";  

    this.getCarouselList();
    this.initNewsList();
  }


  getCarouselList(){
    this.cl=new Array();

    this.newsService.getCarouselList()
    .then((data:any)=>{
      this.cl=data;


    })    
  }

  initNewsList(){
    this.nl=new Array();
    this.newsService.getNewsList()
    .then((data:any)=>{
      this.nl=data;

    })
  }


  goToCarouselDetail(c:Carousel){

    this.navCtrl.push(CarouseldetailPage,{"carousel":c});

  }


  goToNewsDetail(n:News){

    this.navCtrl.push(NewsdetailPage,{"news":n});

  }


}
